package com.rg1906.web;

import java.io.IOException;
import java.sql.SQLException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.rg1906.service.impl.UpdateTeacherServiceImpl;


@WebServlet("/UpdateTeacher")
public class UpdateTeacher extends HttpServlet {
	private static final long serialVersionUID = 1L;
	UpdateTeacherServiceImpl service=new UpdateTeacherServiceImpl();
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String id = request.getParameter("id1");
		String teacherName = request.getParameter("teacherName1");
		String gradeName = request.getParameter("gradeName1");
		String phone = request.getParameter("phone1");
		String sex = request.getParameter("sex1");
		String age = request.getParameter("age1");
		String address = request.getParameter("address1");
		try {
			int gid = service.updateGid(gradeName);
			int i = service.updateTeacher(id,teacherName,gid,phone,sex,age,address);
			if(i>0) {
				response.getWriter().print(true);
			}else {
				response.getWriter().print(false);
			}
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
	}
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
